
 <template>
 	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" >
 		<i class="el-icon-close close" @click="cancel" style="color: white;z-index:10;"></i>
	    <div class="bt">盘点编辑</div>
 		<el-form label-width="100px" class="form">
 			<el-form-item label="物品名称">
 				<el-input v-model="params.row.wpmc" :readonly='true'  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="账面库存数量">
 				<el-input v-model="form.tgtcnt" :readonly='true'  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="实际有效数量">
 				<el-input v-model="form.pdcnt"  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<!--<el-form-item label="盘点人">
 				<el-input v-model="params.row.pdrmc"  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>-->
 			<el-form-item label="盘点说明">
 				<el-input v-model="form.note"  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<span style="font-size: 12px;color: red;">注：实际有效数量小于账面库存数量时 称为 盘亏，可能需要做盘亏处理</span>
 			
 			<el-collapse v-model="activeNames" >
		<el-collapse-item title="盘亏处理" accordion name="1" style="" >
 			<el-form-item label="报修数量" v-if='bxsl'>
 				<el-input v-model="form.bxcnt"   placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="报修原因" v-if='bxyy'>
 				<el-input v-model="form.bxnote"  placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<hr/>
 			<el-form-item label="报损数量" v-if='bssl'>
 				<el-input v-model="form.bscnt"   placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 			<el-form-item label="报损原因" v-if='bsyy'>
 				<el-input v-model="form.bsnote"   placeholder="请输入" class="select-block"></el-input>
 			</el-form-item>
 		</el-collapse-item>

 		</el-collapse>
 		</el-form>
 		<el-button type="primary" class="submit" @click="submit">修改</el-button>
 		<el-button type="danger" class="submit" @click="cancel">退出</el-button>
 	</el-dialog>
 </template>
 <script type="text/javascript">
 	import qs from 'qs'
 	export default {
 		props: ['params'],
 		data() {
 			return {
 					activeNames:'',
 					bxsl:true,
 					bxyy:true,
 					bssl:true,
 					bsyy:true,
 					
 				form: {
//    		           wpid :'',
			           tgtcnt:'',
			           pdcnt:'',
			           bxcnt:'0',
			           bxyy:'',
			           bscnt:'0',
			           bxnote:'',
			           bsnote:'',
			           note :'',
 					 id:''
 				},
 				   comboxlist:[],
 			}
 		},
 		created() {
  		 this.form.id = this.params.row.id;
//		 this.form.wpid = this.params.row.wpid;
//		  this.getcomboxlist();
          this.loadinfo();
; 		},
 		methods: {
 			loadinfo(){
 				
 				var logininfo = JSON.parse(localStorage.logininfo);
             var params2 = qs.stringify({
                             xxid:logininfo.xxid,
 							 yhid:logininfo.id,
 							 id:this.form.id
               })
             //执行
                 this.axios.post(this.$store.state.api + 'wppdmx/info',  params2 )
                 .then(res => {
                 this.form=res.data.data
                  if(this.form.pdcnt<this.params.row.tgtcnt){
            	   	 this.activeNames='1';
            	   }else if(this.form.pdcnt>=this.params.row.tgtcnt){
            	   	this.activeNames='';
            	   }
            	   
                  if(res.data.data.wpfl=='1'){
                  	this.bxsl=false;
                  	this.bxyy=false;
                  }else if(res.data.data.wpfl=='2 '){
                  	this.bxsl=false;
                  	this.bxyy=false;
                  }
                  else if(res.data.data.wpfl=='3'){
                  	
                  }else if(res.data.data.wpfl=='4'){
                  	this.bxsl=false;
                  	this.bxyy=false;
                  }
                 }).catch(res => {
					this.$message.warning("服务器异常");
 			 				this.$emit('close', { type: 'edit', cancel: true });
				})
 			},
 			 submit() {
 				this.$store.state.loading = true;
 				var logininfo = JSON.parse(localStorage.logininfo);
 				var params2 = qs.stringify({
 						id: this.form.id+'',
// 						wpid:this.form.wpid+'',
// 						tgtcnt:this.form.tgtcnt+'',
 						pdcnt:this.form.pdcnt+'',
 						bxcnt:this.form.bxcnt ,
 						bscnt:this.form.bscnt ,
 						bsnote:this.form.bsnote ,
 						bxnote: this.form.bxnote ,
 						note: this.form.note ,
 						yhid: logininfo.id+'',
 						xxid: logininfo.xxid+''
 					})
 				//执行
 				    this.axios.post(this.$store.state.api + 'wppdmx/update',  params2 )
 						.then(res => {
 							if(res.data.code == 1) {
 								this.$emit('close', { type: 'edit', cancel: false });
 								this.$message.success(res.data.msg);
 								this.$store.state.loading = false;
 							} else {
 								this.$message.warning(res.data.msg);
 								this.$store.state.loading = false;
 							}
 						}).catch(res => {
 							this.$message.danger("服务器异常");
 							this.$store.state.loading = false;
 						})
 			},
 			cancel() {
 				this.$emit('close', { type: 'edit', cancel: true })
 			}
 		}
 	}
 </script>
 <style lang="less" scoped>
 	.wrap {
 		text-align: center;
 	}
 	.bt{
		position: absolute;
		width: 100%;
		height: 50px;
		margin: 0 auto;
		top: 0;
		left: 0;
		background: #50BFFF;
		color:white;
		text-align:left;
		line-height: 50px;
		font-size: 17px;
		padding-left: 15px;
	}
 	.form {
 		text-align: left;
 		margin-top: 10px;
 	}
 	.input {
             width: 300px;
             display: inline-block;
         }
 	.select-block {
 		display: block;
 	}
 	.submit {
 		width: 120px;
 	}
 </style>
